﻿@using TD.Common.Kendo.Mvc5.Grid

@model TD.CTS.Data.Entities.Schedule

@section head{
    <link href="@Url.Content("~/Content/td/td.kendo.grid.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/td/td.kendo.tabstrip.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/td/td.kendo.grid.js")"></script>

    <style type="text/css">
        .td-textarea-edit {
            width: 300px !important;
            height: 60px !important;
        }
    </style>
}
@*@{
    var isNew = true;
}*@
@(Html.Kendo().TabStrip()
    .Name("TabStrip")
    .Animation(false)
    .Items(tabs =>{tabs.Add().Text("Основное").Selected(true).Content(@<text>@Html.Partial("EditorTemplates/MainEditor")</text>);}))

<script>
    var validator = $("#scheduleForm").kendoValidator().data("kendoValidator");
    function SaveSchedule() {
        if (validator.validate()) {
            $.ajax({
                type: "POST",
                url: "@Url.Action("AddSchedule", "Schedules")",
                data: {
                    "Id": $("#Id").val(),
                    //"BeginDate": $("#BeginDate").val(),
                    //"BeginDate": $("#BeginDate").data("kendoDatePicker").value().toISOString(),
                    "PatientCode": $("#PatientCode").val(),
                    "TrialCenterID": $("#TrialCenterID").val(),
                    "ScheduleStatus": $("#ScheduleStatus").val(),
                    //"TrialCode": $("#TrialCode").val(),
                    "Comment": $("#Comment").val()
                },
                success: function (result) {
                    $("#SaveButton").attr("disabled", "disabled");
                    var saveNotification = $("#SaveNotification").data("kendoNotification");
                    saveNotification.show("Сохранено", "success");
                    var url = "@Url.Action("Edit", "Schedules")";
                    url = url + "/" + result.Data[0].Id;
                    window.location.replace(url);


                },
                error: AjaxError
        });
    }
    }



    </script>